import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yinsh
 * Date: 2025-01-22
 * Time: 15:06
 */
public class MyCircularQueue {
    int[] circularList;
    int front;
    int rear;
    public MyCircularQueue(int k) {
       circularList = new int[k + 1];
    }

    public boolean enQueue(int value) {
        if (isFull()) {
            return false;
        }
        int len = circularList.length;
        circularList[rear % len] = value;
        rear++;
        return true;
    }

    public boolean deQueue() {
        if (isEmpty()) {
            return false;
        }
        front++;
        return true;
    }

    public int Front() {
        if (isEmpty()) {
            return -1;
        }
            return circularList[front % circularList.length];
    }

    public int Rear() {
        if (isEmpty()) {
            return -1;
        }
            return circularList[(rear - 1) % circularList.length];
    }

    public boolean isEmpty() {
        if (front == rear) {
            return true;
        }
        return false;
    }

    public boolean isFull() {
        int len = circularList.length;
        if ((rear + 1) % len == front) {
            return true;
        }
        return false;

    }

}
